#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
int main()
{

  printf("我是一个父进程，我的pid是%d\n",getpid());

  pid_t id = fork();

  while(1)
  {
    //创建子进程失败
    if(id < 0)
    {
      return 1;
    }
    else if(id == 0)
    {
      printf("我是子进程：pid:%d,ppid:%d,ret:%d,我正在执行下载任务\n",getpid(),getppid(), id);
      sleep(1);
    }
    else{
      printf("我是父进程：pid:%d,ppid:%d,ret:%d,我正在执行下载任务\n",getpid(),getppid(), id);
      sleep(1);
    }
  }
    

  //chdir("/home/Asi/109");

  //FILE* pf = fopen("109.txt", "w");

  //if(pf == NULL) return 1;

  //fclose(pf);

  //int i = 0;
  //for(;i < 100;i ++)
  //{
  //  printf("I am a process: process id:%d, parent id:%d\n",getpid(),getppid());
  //  sleep(1);
  //}
  //
  return 0;
}
